/*

Author   : chaos

FileName : public_inh.cpp

Date     : 13/08/17 22:28:06

*/
#include <iostream>
using namespace std;

class Base
{
    private:
        int pri_att;
        void pri_show()
        {
            cout <<"Base::pri_show() is called!" << endl;
        }
        protected:
        int pro_att;
        void pro_show()
        {
            cout << " Base ::pro_show() is called !" << endl;
        }
        public:

        Base():pri_att(1),pro_att(2),pub_att(3){}
        int pub_att;
        void pub_show(){
            cout << "Base::pub_show() is called !" << endl;
        }
};

class Derived:public Base
{
    public:
        void call_fun();
        void show();
};

void Derived::call_fun()
{
    cout << endl;
    cout << "Derived::call_fun is called" << endl;
    pub_show();
    pro_show();
    //pri_show();
}

void Derived::show()
{
    cout << endl;
    cout << "Derived::show() is called!" << endl;
    cout << "Base::pub_att =" << pub_att << endl;
    cout << "Base::pro_att =" << pro_att << endl;
    //cout << "Base::pri_att =" << pri_att << endl;
}

int main(int argc ,char *argv[])
{
    Derived A_Derived;

    cout << "Accessing Derived's data members" << "inherited form Base ..." << endl;
    cout << "Derived::pub_att = " << A_Derived.pub_att << endl;
    //cout << "Derived::pro_att = " << A_Derived.pro_att << endl;
    //cout << "Derived::pri_att = " << A_Derived.pri_att << endl;

    cout << endl;

    cout << "Call Derived's member functions " << "inherited form Base..." << endl;
    A_Derived.pub_show();
    //A_Derived.pro_show();
    //A_Derived.pri_show();

    A_Derived.call_fun();

    A_Derived.show();
    return 0;
}
